import tailwindcss from "@tailwindcss/vite";

export default defineNuxtConfig({
  ssr: true,
  compatibilityDate: "2025-05-15",
  devtools: {
    enabled: true,
  },
  devServer: {
    port: 5173,
  },
  modules: ["@tdesign-vue-next/nuxt"],
  runtimeConfig: {
    public: {
      apiBase: process.env.NUXT_PUBLIC_API_BASE,
      version: process.env.NUXT_PUBLIC_VERSION,
      host: process.env.NUXT_PUBLIC_HOST,
      isShowCPU: process.env.NUXT_PUBLIC_CPU,
    },
  },
  build: {
    analyze: true,
  },
  app: {
    head: {
      link: [
        { rel: "dns-prefetch", href: "//html5.gamemonetize.com" },
        { rel: "dns-prefetch", href: "//h5boardpro.com" },
        { rel: "dns-prefetch", href: "//kopah5.com" },
        { rel: "dns-prefetch", href: "//mogoh5.com" },
        { rel: "dns-prefetch", href: "//acth5games.com" },
        { rel: "dns-prefetch", href: "//ggbondh5.com" },
      ],
      script: [
        {
          src: "https://securepubads.g.doubleclick.net/tag/js/gpt.js",
          crossorigin: "anonymous",
          defer: true,
        },
      ],
    },
  },
  vite: {
    plugins: [tailwindcss()],
    clearScreen: true, // 启动时清空控制台
    build: {
      minify: "esbuild", // 构建时是否进行代码压缩
      sourcemap: false, // 打包时是否生成 sourcemap 文件
      rollupOptions: {
        output: {
          chunkFileNames: "_nuxt/[name].[hash].js",
          entryFileNames: "_nuxt/[name].[hash].js",
          assetFileNames: "_nuxt/[name].[hash].[ext]",
        },
        cache: true, // 缓存
      },
      cssCodeSplit: true, // 是否开启css代码分割
      chunkSizeWarningLimit: 100, // 构建时超过这个阈值的文件打包会标黄
      reportCompressedSize: true, // 构建时是否生成 gzip 压缩包
      assetsInlineLimit: 10000, // 10000=10kb，当静态资源小于10kb时候，会被转换为base64打入js文件
    },
    css: {
      modules: {
        generateScopedName: "[hash:base64:5]_[local]", // css module
      },
    },
  },
  css: ["@/public/css/daisyui.css", "@/public/css/index.css"],
});

